package com.innoking.docsys.user.controller;

import com.innoking.docsys.search.module.FileTxtVO;
import com.innoking.docsys.user.service.NlpService;
import com.innoking.docsys.utils.JsonToOtherUtil;
import com.innoking.docsys.utils.OtherPojo;
import com.innoking.docsys.utils.ResultObjVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * ClassName: Hello
 * Function:  TODO
 * Date:      2019/8/22 14:33
 * author     yeruixaing
 * QQ:        3141684159
 * version    V1.0
 */
@Controller
@CrossOrigin
public class NlpController {

    @Autowired
    private NlpService nlpService;

    @RequestMapping(value = "getList")
    @ResponseBody
    public List getList(HttpServletRequest req, HttpServletResponse resp) {
        List list = nlpService.getList();
        return list;
    }

    @PostMapping(value = "addOrUpdateNpl")
    @ResponseBody
    public ResultObjVO addNpl(HttpServletRequest req, HttpServletResponse resp, String searchStr) {
        OtherPojo otherPojo = JsonToOtherUtil.rtOtherPojo(searchStr, new FileTxtVO());
        FileTxtVO obj = (FileTxtVO)otherPojo.getObj();
        String str = obj.getFileTxt();
        ResultObjVO code = nlpService.addOrUpdateNpl(str);
        return code;
    }

}
